package cn.zjyj.module.zjyj.dal.mysql.device;

import cn.zjyj.framework.common.common.pojo.PageResult;
import cn.zjyj.framework.datasource.mybatis.core.query.LambdaQueryWrapperX;
import cn.zjyj.framework.datasource.mybatis.core.mapper.BaseMapperX;
import cn.zjyj.module.zjyj.dal.dataobject.device.DeviceDO;
import org.apache.ibatis.annotations.Mapper;
import cn.zjyj.module.zjyj.controller.admin.device.vo.*;

/**
 * 设备 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface DeviceMapper extends BaseMapperX<DeviceDO> {

    default PageResult<DeviceDO> selectPage(DevicePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeviceDO>()
                .betweenIfPresent(DeviceDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(DeviceDO::getName, reqVO.getName())
                .eqIfPresent(DeviceDO::getSupplierId, reqVO.getSupplierId())
                .eqIfPresent(DeviceDO::getGroupId, reqVO.getGroupId())
                .eqIfPresent(DeviceDO::getBrand, reqVO.getBrand())
                .eqIfPresent(DeviceDO::getModel, reqVO.getModel())
                .eqIfPresent(DeviceDO::getSpecification, reqVO.getSpecification())
                .eqIfPresent(DeviceDO::getIsSpecialEquipment, reqVO.getIsSpecialEquipment())
                .eqIfPresent(DeviceDO::getUseDescribe, reqVO.getUseDescribe())
                .eqIfPresent(DeviceDO::getIsNeedRepair, reqVO.getIsNeedRepair())
                .eqIfPresent(DeviceDO::getRepairCycle, reqVO.getRepairCycle())
                .eqIfPresent(DeviceDO::getRepairPermitCard, reqVO.getRepairPermitCard())
                .eqIfPresent(DeviceDO::getRepairReason, reqVO.getRepairReason())
                .eqIfPresent(DeviceDO::getIsNeedMaintain, reqVO.getIsNeedMaintain())
                .eqIfPresent(DeviceDO::getMaintainCycle, reqVO.getMaintainCycle())
                .eqIfPresent(DeviceDO::getIsNeedFitMetering, reqVO.getIsNeedFitMetering())
                .eqIfPresent(DeviceDO::getFitMeteringCycle, reqVO.getFitMeteringCycle())
                .orderByDesc(DeviceDO::getId));
    }

}